const TaskQueue = require('./src/index.js');

const taskQueue = TaskQueue({
  asyncMax: 5,
});

taskQueue.progressBar.describe('加载中...');
for (let i = 0; i < 97; i += 1) {
  taskQueue.add(task, `describe-${i}...`, `title-${i}:`, `data-${i}`);
}
taskQueue.start();

function task(data, index) {
  return new Promise((resolve) => {
    setTimeout(() => {
      if (index === 30) {
        /* taskQueue.stop().then(() => {
          console.log('[stop ] end', new Date());
        }); */
      }
      resolve();
    }, 100000 * Math.random());
  });
}
